package com.ying.user.service.impl;

import com.ying.common.entity.Response;
import com.ying.user.dao.MmPermissionDao;
import com.ying.user.entity.MmPermission;
import com.ying.user.service.MmPermissionService;
import com.ying.user.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.function.Function;

@Service
public class MmPermissionServiceImpl implements MmPermissionService {

    @Autowired
    private MmPermissionDao mmPermissionDao;

    @Override
    public Function<MmPermission, Response> add() {
        return (mmPermission) -> {
            Response response = new Response();
            mmPermission.setCreateTime(DateUtils.getDateTime());
            mmPermission.setUpdateTime(DateUtils.getDateTime());
            int i = mmPermissionDao.insertSelective(mmPermission);
            return i > 0 ? response.success("添加权限成功") : response.failure("添加权限失败");
        };
    }
}
